﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Rapid.WebNecessary
{
    /// <summary>
    /// 服务器 Session 状态集群管理
    /// </summary>
    public class PartitionResolver : IPartitionResolver
    {
        private String[] partitions;

        public void Initialize()
        {
            partitions = new String[] 
            {       
                "tcpip=127.0.0.1:42424"
            };
        }

        public string ResolvePartition(object key)
        {
            string sessionId = key as string;

            int partitionID = Math.Abs(sessionId.GetHashCode()) % partitions.Length;

            return partitions[partitionID];
        }
    }
}